import React from "react";
import {Divider, Timeline,Layout, Button,  Form, Col, Row} from "antd/lib";
import Contracts from "@/services/contracts";
import {BrowserRouter as Router, Link} from "react-router-dom";
import {createBrowserHistory} from "history";
import {AlertTwoTone} from "@ant-design/icons";
const {Sider,Content } = Layout;
const customHistory = createBrowserHistory();
export default class SealTimeLine extends React.Component {
  state = {
    loading: true,
    data:[],//合同活动列表
  };
  componentWillMount() {
   Contracts.getactivity({id: this.props.id,sourcetype: 'contractseal'}).then(data => {
       if(data.length>0) {
         this.setState({
           data: data,
           loading: false,
         });
       }else{
          this.setState({
            loading: false,
          });
       }
      }).catch(error => {
          this.setState({
            loading: false,
          });
        });
  }
    pushbill = (items) => {
      if(items.sourcetype==="contractapply" ){
          return (<Timeline.Item dot={<i className="fa fa-home m-r-5" />} color="blue">
          {items.created_at +'  ' + items.message + '  '}
          </Timeline.Item>);
        }else if(items.sourcetype==="contracts" ){
          return (<Timeline.Item dot={<i className="fa fa-home m-r-5" />} color="blue">
            {items.created_at +'  ' + items.message + '  '}</Timeline.Item>);
        }else if(items.sourcetype==="contractseal" ){
          return (<Timeline.Item dot={<i className="fa fa-gavel m-r-5" />} color="blue">
            {items.created_at +'  ' + items.message + '  '}</Timeline.Item>);
        }else if(items.sourcetype==="contractrecord" ){
          return (<Timeline.Item dot={<i className="fa fa-briefcase m-r-5" />} color="blue">
            {items.created_at +'  ' + items.message + '  '}</Timeline.Item>);
        }else if(items.sourcetype==="contractchange" ){
          return (<Timeline.Item dot={<i className="fa fa-home m-r-5" />} color="blue">
            {items.created_at +'  ' + items.message + '  '}</Timeline.Item>);
        }else if(items.sourcetype==="contractprogress" ){
          return (<Timeline.Item dot={<i className="fa fa-tablet m-r-5" />} color="blue">
            {items.created_at +'  ' + items.message + '  '}</Timeline.Item>);
        }else if(items.sourcetype==="contractsettle" ){
          return (<Timeline.Item dot={<i className="fa fa-database m-r-5" />} color="blue">
            {items.created_at +'  ' + items.message + '  '}</Timeline.Item>);
        }else if(items.sourcetype==="contractstop" ){
          return (<Timeline.Item dot={<i className="fa fa-close m-r-5" />} color="blue">
            {items.created_at +'  ' + items.message + '  '}</Timeline.Item>);
        }else if(items.sourcetype==="contractfinish" ){
          return (<Timeline.Item dot={<i className="fa fa-file m-r-5" />} color="blue">
            {items.created_at +'  ' + items.message + '  '}</Timeline.Item>);
        }
  };
    render() {
     if (this.state.loading) return null;
      return (
          <div>
              <Divider type="horizontal" />
                  <Timeline style={{ background: '#fff'}}>
                  {(this.state.data || []).map(item => (
                      this.pushbill(item)
                    ))}
                  </Timeline> 
        </div>
      );
    }
}
